#pragma once
#include "ProtkCallback.h"


using namespace boost;

namespace pyBind{


	template<typename tktype>
	struct ParsePyObject_T
	{
		int operator()(tktype *tkp, PyObject * pyObj) {
			*tkp =	pyObj;
			return 1;
		}
	};

	template<>
	struct ParsePyObject_T<int>
	{
		int operator()(int *tkp, PyObject * pyObj) {
			if(PyLong_Check(pyObj))
				*tkp = PyLong_AsLong(pyObj);
			else
				assert(("PyLong_Check fail!",0));
			return 1;
		}
	};
	template<>
	struct ParsePyObject_T<double>
	{
		int operator()(double *tkp, PyObject * pyObj) {
			if(PyFloat_Check(pyObj))
				*tkp = PyFloat_AsDouble(pyObj);
			else
				assert(("PyFloat_Check fail!",0));
			return 1;
		}
	};


	template<typename ret ,typename arg0,typename arg1,typename arg2>
	struct ParsePyObject_T<ret (*)(arg0,arg1,arg2)>
	{
		typedef ret (*funtype3)(arg0,arg1,arg2);
		int operator()(funtype3* tkp, PyObject * pyObj) {
			if(PyCallable_Check(pyObj))
			{
				*tkp = (ProUIAction)CallBackCodeGen_3(pyObj ,&Py_ProUIAction);
				//*tkp = pyProUIAction;
			}
			else
				assert(("PyCallable_Check fail!",0));
			return 1;
		}
	};


	template<typename tktype ,bool isenum = false>
	struct ParsePyObject_Enum :ParsePyObject_T<tktype>
	{
	};

	template<typename tktype >
	struct ParsePyObject_Enum<tktype,true>
	{
		int operator()(tktype *tkp, PyObject * pyObj) {
			return ParsePyObject_T<int>()((int*)tkp,pyObj);
		}
	}; 

	template<typename tktype>
	struct ParsePyObject:ParsePyObject_Enum<tktype,is_enum<tktype>::value>
	{
	};
}